home *** CD-ROM | disk | FTP | other *** search
/ Varios Español / Varios Español.iso / DBASE5 / CUA_SAMP.ZIP / FILEPATH.PRG < prev    next >
Text File  |  1994-10-12  |  1KB  |  48 lines

  1. FUNCTION FilePath
  2. PARAMETER pc_fname
  3. *--------------------------------------------------------------------
  4. * NAME
  5. *   FilePath - Returns path portion of a complete filespec.
  6. *
  7. * SYNOPSIS
  8. *   FilePath( pc_fname )
  9. *
  10. * DESCRIPTION
  11. *   FilePath() returns the path from the full
  12. *   description of the file specified by pc_fname.
  13. *   The drive letter, if any, is not returned.
  14. *
  15. *   If the filespec does not contain a path, the
  16. *   null string ("") is returned.
  17. *
  18. * PARAMETER
  19. *   pc_fname - A character full DOS filespec.
  20. *
  21. * EXAMPLE
  22. *   lc_fpath = FilePath( "C:\TEST\FOO.PRG" )
  23. *     ( lc_fpath will equal "\TEST\" )
  24. *
  25. *   lc_fpath = FilePath( "MYFILE.TXT" )
  26. *     ( lc_fpath will equal "" )
  27. *
  28. * SEE ALSO
  29. *   _FILEDRV(), _FILEROOT(), _FILETYPE()
  30. *
  31. *--------------------------------------------------------------------
  32.   PRIVATE ln_pathpos, lc_slash, nLastSlash
  33.  
  34.   nLastSlash = RAT( "\", m->pc_fName )
  35.   isDrive = AT( ":", m->pc_fName ) = 2
  36.   IF m->isDrive
  37.     ln_PathPos = 3
  38.   ELSE
  39.     ln_PathPos = 1
  40.   ENDIF
  41.  
  42. RETURN( IIF( m->ln_pathpos > 0, ;
  43.              SUBSTR( m->pc_fname, m->ln_pathpos, ;
  44.                      m->nLastSlash - m->ln_pathpos + 1 ),;
  45.              "" ) )
  46. *-- EOF: FilePath( pc_fname )
  47.  
  48.